/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utility.com;

/**
 *
 * @author jay
 */
public class TableColumnComparator {
     protected boolean isSortAsc;

  public TableColumnComparator( boolean sortAsc) {
    isSortAsc = sortAsc;
  }

  public int compare(Object o1, Object o2) {
    if (!(o1 instanceof Integer) || !(o2 instanceof Integer))
      return 0;
    Integer s1 = (Integer) o1;
    Integer s2 = (Integer) o2;
    int result = 0;
    result = s1.compareTo(s2);
    if (!isSortAsc)
      result = -result;
    return result;
  }

  public boolean equals(Object obj) {
    if (obj instanceof TableColumnComparator) {
      TableColumnComparator compObj = (TableColumnComparator) obj;
      return compObj.isSortAsc == isSortAsc;
    }
    return false;
  }
}
